package com.bms.service.impl;

import javax.annotation.Resource;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Service;

import com.bms.dao.UserDao;
import com.bms.entity.User;
import com.bms.httpModel.Pager;
import com.bms.service.UserService;

/**
 * Service实现类 - 管理员
 */
@Service
public class UserServiceImpl extends BaseServiceImpl<User, String> implements UserService {

	@Resource
	private UserDao userDao;

	@Resource
	public void setBaseDao(UserDao userDao) {
		super.setBaseDao(userDao);
	}

	/**
	 * @return the userDao
	 */
	public UserDao getUserDao() {
		return userDao;
	}

	/**
	 * @param userDao the userDao to set
	 */
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}
	
	/**
	 * 用户分页
	 * 列表中排除登录用户
	 */
	public Pager<User> findByPager(Pager<User> pager, String loginUserName) {
		DetachedCriteria criteria = DetachedCriteria.forClass(User.class);
		criteria.add(Restrictions.not(Restrictions.eq("username", loginUserName)));
		pager.setDetachedCriteria(criteria);
		return userDao.findByPager(pager);
	}

}